{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from tensorflow.keras.preprocessing.image import ImageDataGenerator\n",
    "from tensorflow.keras.models import Sequential\n",
    "from tensorflow.keras.layers import Dropout, Flatten, Dense\n",
    "from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input\n",
    "from dogcat_data import generators, get_nb_files\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "top_model_weights_path = 'bottleneck_fc_model.h5'\n",
    "train_dir = 'dogcat-data/train'\n",
    "validation_dir = 'dogcat-data/validation'\n",
    "nb_train_samples = 1000\n",
    "nb_validation_samples = 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 1800 images belonging to 2 classes.\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAkkAAAEzCAYAAAAl0ZcOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3XmQ1fWV///XkaUbGpBVloZmdUUNGEWJiJqAiVbMEJcxZaITU8ZxzEysVIyTSn1nrN+MSdSpVFxSJJNMrGxO4iRBI2ipqKioLCqLuLBKszTQQgPN0kCD3t8ffbvqar3PuZdumr59+/moshI+L9/N59zP53P77e0+77dlMhkBAADg405o7xMAAAAoRkySAAAAEpgkAQAAJDBJAgAASGCSBAAAkMAkCQAAIKGoJ0lm9hszu7u9z6OtlHp9EjWWilKvsdTrkzpHjcCxVtSTJAAA2oKZVZvZtPY+j7ZS6vVJx6dGJkkAAAAJRTVJMrOJZr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kMpkD7XtKx1Sp1ydRY6ko9RpLvT6pc9QIFKTkftwGAABwLJTKJ0kAAADHFJMkAACAhE8u3HRMXHzxxe7P8CorK91xZWVlbnboULoDdc2aNe6Y6upqN9u/f7+bNTQ0mBtK6tOnj1tfY2OjO6579+7R10we79KlizvmwAH/1wQ+vobcx9XW1ob1SdLpp5/u1jh+/Hh3XE1NjZt512PUqFHumK1bt7rZrl273Ky+vj5vjXfccYdb47vvvuuOW79+vZt599X111/vjqmqqnKzFStWuNnPf/7zvDXeeuutbo2rVq1yxx05csTNvHuyrq7OHRM9F127+m9D77zzTljj8OHD3fqi+yp6rjzR8/vGG2+4WfQrDbt37857DS+44AL3C7z//vvuuOg9bsSIEcnj48aNi87DzaLX5s4778xb4+WXX96iZ9F735Skq666Knk8uva/+tWv3Oyjjz5ys5qamrw1jhw5skW/29KzZ083857THTt2uGO876WSdOKJJ7rZ1q1bwxrvvPNOt74bb7zRHffwww+72ZIlS5LH161b547Zvn27m0W1ZzKZZH18kgQAAJDAJAkAACCBSRIAAEACkyQAAIAEJkkAAAAJbdLddtttt7lZ1BkVdcds2rQpefxf//Vf3TH19fVu9uGHH7pZPnv37nWzE07w551Rx9C5556bPN67d293zJ49e9xs4cLW7SKwc+dONzt48KCbRV1M3vX9h3/4B3fMlClT3GzWrE/udXh0+vbt62aXX365my1YsMDNvE61//zP/3THRF0z//zP/+xmhYg6YwYPHuxmAwcOdDPvPt6wYYM7Juq2iTpV8ok6Yrdt2+ZmY8eOdbObb745eTzqioq6d6LnvhDR6xp18vTo0cPNovdGT0ufiULs3r3bzaIOtui+mj9/fvJ4Q0ODOyZ6b5s+fbqbFaK2ttbNou9H0fvjLbfckjwedRl/+9vfdrMtW7a4WT7R977ofC655BI387qCn3vuOXfMI4884mZRx7uHT5IAAAASmCQBAAAkMEkCAABIYJIEAACQwCQJAAAggUkSAABAQpssARA544wz3CxqIVy0aFHyeNSyGbVWR5tO5hNtyBltEBjV5y0r4G1EKcXLA0St34WIlhe48MIL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XDbWtEGr+eff76bXXTRRcnjF198sTsm2vj4kUcecbNCRBuPRs9btCHlc889lzwePRfexr9S3Fqfz7Jly9ysb9++bhZtcLtixYrk8aiN+Uc/+pGb7dixw80KES1XEi09EC3/4G0qHS39ELXARy38hejRo4ebffnLX3azyy67zM2qqqqSx8877zx3TPSa/fznP3ezQkT3XLR8RrRszvr165PHoyVMoqV2omVB8oneM/793//dzaqrq91s48aNyePRfTpixAg327Bhg5t5+CQJAAAggUkSAABAApMkAACABCZJAAAACUySAAAAEpgkAQAAJLTJEgBeq7cU7/jrtWxKfototHtytEP0W2+95Wb5RO3M0flErc5eO/agQYMKP7EcH330UYvGNYtaehsaGtzspptucjOvvXbx4sXumGiH+L1797pZIaI22eHDh7vZnj173GzlypXJ49G96LW5SvFrXYjevXu3KPvMZz7jZt75Ll++vPATyxHt2p1PtFRF1CYc3d/e+URLAKxbt87Nouc+Wv6hWXSfvv/++2527rnnupm3LEFNTY07JmpFb0lrda6oPT5q84++n3jXJKpx0aJFbhYtp1GIiRMnutkZZ5zhZlFLu/c+Fb2nRjW25vvG888/72azZs1ys507d7rZvHnzksejeyJ6TqPv3R4+SQIAAEhgkgQAAJDAJAkAACCBSRIAAEACkyQAAICENuluizodBg8e7GY//elP3WzIkCHJ46tXr3bHHDlyxM2iTSPzibpNou62tWvXutns2bOTx1vy2/iS1LNnzxaNaxZtrBt1L0YdZ+ecc07y+JIlS9wx3gaO+c6jEFF31/Tp092sJZ1Rb775pjsm6gqLNo0txOHDh90s6mSJOu68jWOj+zt6FqMNjvOJuqLWrFnjZtH97T07L7/8sjsmqi86R++ZyBXdb/fee6+bzZgxw828jruoEy96L2ptN220IXfU/dSSzdT79Onjjok636J7phCbN292s6hz7rHHHnMz73yjjdaj99vKyko3yyfayPnpp592s6h7z3uu3nnnHXdM9NxHG2J7+CQJAAAggUkSAABAApMkAACABCZJAAAACUySAAAAEpgkAQAAJLTJEgBR2/G2bdvcLNrkz2v3jtr9onbO1rSsDhgwwM369evnZu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M8+cOXPcLKpx+HB/rcK1a9fmrfGkk05ya4yenQMH/F+z8d5To/fG6PvGhx9+6Gb5vm+Ul5e79UXPR/S9qry8PHm8Z8+e7pio9mjc8uXLk/XxSRIAAEACkyQAAIAEJkkAAAAJTJIAAAASmCQBAAAktEl326BBg9zs+uuvd7PoN+u97omo82HBggVuNnfuXDfL55133nGz0047zc0mT57sZq+++mry+Nlnn+2OOfHEE91s3rzWbV8TdXJ8/vOfd7OoE2PlypXJ47W1te6Yfv36uVnUpVGIbdu2udkdd9zhZmeeeaabvfLKK8nj//RP/+SOibowo66QQkTjozqizrBTTjkleXzgwIHumI0bN7rZCy+84Gb5eF1aUvx83H777W7mdZRG5/nII4+4WfQeVYitW7e6WdSlF3VqXXjhhcnj1157rTtm06ZNbjZz5kw3K8SVV17pZj/4wQ/cLOru27JlS/L4rFmz3DHR8/LZz37WzQoRfe1Pf/rTLfqaXo2nn366OybqXG3N943u3bu72UcffeRmUbewd65RB9ukSZPcLHpePHySBAAAkMAkCQAAIIFJEgAAQAKTJAAAgAQmSQAAAAlMkgAAABLaZAmAqI00WgJg4cKFbtanT5/k8ahVPWoRj9q/89m+fbubfetb33KzmpoaN+vaNX0ppkyZ4o55/fXX3SzaNLUQO3bscLNok8Dvf//7bua1c37pS19yx3gbxkrx5r+FePPNN90sasuPeC3JmzdvdsdErdpRK34hotbbL37xi252/vnnu5n3unvtyJK0evVqN3v++efdLJ/9+/e72Q033NCirK6uLnnc24Rakh5++GE3i5Y2KcS5557rZuvWrXOzaJPmG2+8MXn86quvdse8//77bva///u/blaIqH182bJlbha9tm+99Vby+HXXXeeOqaiocLOpU6e6WSGiTYDHjBnjZtGSM3//93+fPB59H2ppO34+0ebI0T08YcIEN/O+j40YMcIdM3jwYDd76aWX3MzDJ0kAAAAJTJIAAAASmCQBAAAkMEkCAABIYJIEAACQwCQJAAAgoU2WAFiwYIGbjRw50s2+9rWvuZm3k3a0C3TUqh/trJ3PQw895GbTp093s7vuusvNvF2bvXZkKd7FfezYsW5WiOjvveeee9wsasv3lg4YMmSIOyZqK4/OsRDR13766afdLNqB2mtlHjdunDvm7bffdrPWto9HO34PHTrUzS666CI327t3b/J41CIfvZ5RS3I+F1xwgZtFS1X84Q9/cDPvvnruuefcMdEO760VLWUStUKvXLnSzbxlF6JnYsmSJW4WXftCREsZRO3j3tIwkajNP3qto1b8QnjPjRQvSXPw4EE3895vGhoa3DGjR492s27durlZPmVlZW524MABN4veT71rFZ3nZZdd5mbPPPOMm3n4JAkAACCBSRIAAEACkyQAAIAEJkkAAAAJTJIAAAAS2qS7LdqQcODAgW62du1aN6utrU0ejzp0li9f7mYt3cBUkv72t7+5mXeekt+hJ/ldSJ/61KfcMVHXx5w5c9ysEFF3RNTF8OCDD7qZt0Fk1KESdc205hpKcR3RhrTPPvusm3ndGJdffrk7Jtrg8a9//aubFSLaVPO///u/3eyrX/2qm0WbSnuizVZb090WdXCVl5e7WdTh5F37RYsWuWOiZ7s19UnSU0895WbRZp4nnOD/N7D37ESvZ9SFuWfPHjcrRLRRcVRHdC9612vjxo3umOg+bW0HXyTq8IreH7x7a8WKFe6Y6D0l6sDLJ/reHnWhRh283vWINn6Pvi9Gmxt7+CQJAAAggUkSAABAApMkAACABCZJAAAACUySAAAAEpgkAQAAJLTJEgDR5nNRu1+06azXYtrY2OiOiTYGbI2HH37YzaL6os1GvQ0OL7nkEnfM/ffff9Rfr1BR+3T//v3dLKp//vz5yeNRa23UGhwtU1CI0047zc2iDRlfffVVN/NawaPXM9qo9/Dhw25WiKj9vKamxs1uvfVWN/M2qV61apU7pr6+3s1aI3qmomt45MgRN/M2aY7+rpYs71GoqGU92sQ3auf2zil6z4ye09ZuxDx37lw3mzFjhptF19jbNDy6FxcvXuxm0RI1hfA2o833tSsrK93MuybR99JoeYDW3KvR8gnRax4t1bN+/frk8WiJkmj5lpYsX8InSQAAAAlMkgAAABKYJAEAACQwSQIAAEhgkgQAAJDAJAkAACDBol3CW+r00093v2jUKhu1kXot7VGLc5RFra6HDx8O+yDLy8vd+s477zx33Lhx49zMa3Xs16+fOyZquYxag//2t7/l7fPs16+fW2P0taOWXO81j5ZxiK5hWVlZdB55a4yu44gRI9xxvXr1cjPvmkTXavv27W4WPROZTCZvjd27d2/RA96nTx8385YziNp8o+ct2uX90KFDYY0DBgxw64uenej6eq3z0ZIJUXt8RUWFm9XV1eW9hj179nRrHDx4cL7hSd79GN1v3jIs+cYVcp8OGzbMrTHauT1qj4+WKvFcc801bvbDH/7Qze699968NXbp0sWtMXoGunb1V+rxltuJlhuI/q5o2Yh876nR+2n0PSN6b/CW6pg6dao7pqqqys285Usk6a677krWxydJAAAACUySAAAAEpgkAQAAJDBJAgAASGCSBAAAkMAkCQAAIKFNlgAAAADo6PgkCQAAIIFJEgAAQAKTJAAAgAQmSQAAAAlMkgAAABKYJAEAACQwSQIAAEhgkgQAAJDAJAkAACCBSRIAAEACkyQAAIAEJkkAAAAJTJIAAAASmCQBAAAkMEkCAABIYJIEAACQwCQJAAAggUkSAABAApMkAACABCZJAAAACUySAAAAEpgkAQAAJDBJAgAASPj/Aeks77OrTG5qAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x360 with 40 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "datagen = ImageDataGenerator(preprocessing_function=preprocess_input)\n",
    "\n",
    "# build the VGG16 network\n",
    "model = VGG16(include_top=False, weights='imagenet')\n",
    "generator = datagen.flow_from_directory(\n",
    "        train_dir,\n",
    "        target_size=(224, 224),\n",
    "        batch_size=40,\n",
    "        class_mode='binary')\n",
    "images, labels = next(generator)\n",
    "features = model.predict(images)\n",
    "plt.rcParams['figure.figsize'] = (10,5)\n",
    "for i in range(40):\n",
    "    feature = np.sum(features[i], 2)\n",
    "    feature *= 255.0 / feature.max()\n",
    "    plt.subplot(4,10,i+1)\n",
    "    plt.imshow(feature, cmap='gray',)\n",
    "    plt.title(\"cat\" if labels[i] else \"dog\")\n",
    "    plt.axis('off')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
